package com.example.evanproject.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.evanproject.config.UpdateImg;
import com.example.evanproject.domain.Courselesson;
import com.example.evanproject.service.CourselessonService;
import com.example.evanproject.mapper.CourselessonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
* @author hanxiaoqi
* @description 针对表【courselesson】的数据库操作Service实现
* @createDate 2024-03-09 21:52:12
*/
@Service
public class CourselessonServiceImpl extends ServiceImpl<CourselessonMapper, Courselesson>
    implements CourselessonService{
    @Autowired
    private CourselessonMapper  courseLessonMapper;



    public Courselesson selectbyid(Integer id){
        return courseLessonMapper.selectbyid(id);
    }

    public Integer addcourselesson(Courselesson courseLesson) {
        courseLessonMapper.addcourselesson(courseLesson);
        return courseLesson.getLsId();
    }
    /*添加课时信息(就是在课时的那个id 修改内容)*/
    public Integer addlessoninfo(Integer lsId, String text) {
        return courseLessonMapper.addlessoninfo(lsId,text);
    }

    /*上传图片*/
    public Integer updateviod(MultipartFile file, Integer lessonid,Integer type) {
        String voidename="";
        if(file!=null&&type==0){
            voidename= UpdateImg.updateimg(file);

        }
        if(file!=null&&type==1){
            voidename= UpdateImg.updateimg2(file);
        }
        return  courseLessonMapper.updateviod(voidename,lessonid,type);
    }



}




